Calculator


Select Size first!

Overview

LU Decomposition was developed by Alan Turing as a way to better solve Linear Systems.

Since then, there are many different ways to LU decompose. This is a calculator to decompose a matrix here of less than or equal to 6x6. I want to flesh out this page a bit more in the future, but for now know that the calculator used is Crout's algorithm. The wikipedia page has the algorithm written in C. I have converted it to Javascript. I got the idea from Numerical Methods in C. I would just reccomend looking at the algorithm in C, it is not too hard to convert it to javascript.


                    
    void crout(double const **A, double **L, double **U, int n) {
    int i, j, k;
    double sum = 0;

    for (i = 0; i < n; i++) {
        U[i][i] = 1;
    }

    for (j = 0; j < n; j++) {
        for (i = j; i < n; i++) {
            sum = 0;
            for (k = 0; k < j; k++) {
                sum = sum + L[i][k] * U[k][j];	
            }
            L[i][j] = A[i][j] - sum;
        }

        for (i = j; i < n; i++) {
            sum = 0;
            for(k = 0; k < j; k++) {
                sum = sum + L[j][k] * U[k][i];
            }
            if (L[j][j] == 0) {
                printf("det(L) close to 0!\n Can't divide by 0...\n");
                exit(EXIT_FAILURE);
            }
            U[j][i] = (A[j][i] - sum) / L[j][j];
        }
    }
}
                    

Sourced from: Wikipedia


Here is a good video on the subject: